const response = {
  status: 200,
  message: '获取权限数据成功',
  meta: {
    total: 3,
    pagesize: 10,
    pagenum: 1
  },
  data: []
}

const list = [
  { id: 101, authName: '商品管理', level: '0', pid: 0, path: 'goods' },
  { id: 102, authName: '订单管理', level: '0', pid: 0, path: 'orders' },
  { id: 103, authName: '权限管理', level: '0', pid: 0, path: 'rights' },
  { id: 104, authName: '商品列表', level: '1', pid: 101, path: 'goods' },
  { id: 105, authName: '添加商品', level: '2', pid: 104, path: 'goods' }
]

const tree = [
  {
    id: 11,
    authName: '商品管理',
    path: 'goods',
    // 角色权限（二级）
    children: [
      {
        id: 111,
        authName: '商品列表',
        path: 'goods',
        // 角色权限（三级）
        children: [
          {
            id: 1111,
            authName: '商品管理',
            path: 'goods'
          }
        ]
      },
      {
        id: 112,
        authName: '分类参数',
        path: 'params',
        children: [
          {
            id: 1121,
            authName: '获取参数列表',
            path: 'categories'
          },
          {
            id: 1122,
            authName: '创建商品参数',
            path: 'categories'
          },
          {
            id: 1123,
            authName: '删除商品参数',
            path: 'categories'
          }
        ]
      },
      {
        id: 113,
        authName: '商品分类',
        path: null,
        children: [
          {
            id: 1131,
            authName: '添加分类',
            path: null
          }
        ]
      }
    ]
  },
  {
    id: 12,
    authName: '订单管理',
    path: 'orders',
    children: [
      {
        id: 121,
        authName: '订单列表',
        path: 'orders'
      }
    ]
  }
]

export default {
  'get|rights/(?<type>\\w+)': option => {
    var result = option.url.match('rights/(?<type>\\w+)')
    if (result.groups.type === 'list') {
      response.data = list
    } else if (result.groups.type === 'tree') {
      response.data = tree
    }
    return response
  }
}
